package com.glela.order.model.response;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.glela.order.model.OrderObject;
import com.glela.order.model.PayTypeConfig;

public class OrderObjectVo {
	private Long				orderObjectId;
	private String				orderSn;
	private Long				userId;
	private int					totalPrice;
	private int					totalSettlementPrice;
	private int					cashCoin;
	private int					balancePaid;
	private int					promotionId;
	private int					promotionDiscount;
	private Integer				redPacketId;			//红包ID
	private Long				redPacketFee;			//红包抵扣金额
	private int					totalFee;
	private int					commisionFee;
	private String				payTime;
	private Integer				payType;
	private int					memberDeliveryAddressId;
	private int					deliveryWay;
	private int					isBill;
	private int					billType;
	private String				billHeader;
	private int					freight;
	private int					paymentFee;
	private String				linkMan;
	private String				mobile;
	private String				province;
	private String				city;
	private String				area;
	private String				street;
	private String				address;
	private Double				lon;
	private Double				lat;
	private String				refundDate;
	private int					refundFee;
	private int					refundCashCoin;
	private String				remark;
	private int					inState;
	private String				inDate;
	private String				inVerification;
	private int					procedureFee;
	private int					bankIn;
	private String				createTime;
	private String				updateTime;
	private int					status;
	private int					refund;
	private int					refundStartTime;
	private int					commentStatus;
	private String				payId;
	private String				payUrl;
	private List<PayTypeConfig>	payTypeConfigList;
	private List<OrderInfoVo>	orderInfoVoList;		// 子订单列表
	private String				taxpayerNo;
	private String				remainingTime;
	private String				leftTime;
	private Long				oActivDiscountFee;		//活动折扣金额
	private int isOverseasOrder;// 是否是海外购 1是 0不是

	public OrderObjectVo() {}

	public OrderObjectVo(OrderObject orderObject) {
		super();
		this.orderObjectId = orderObject.getId();
		this.orderSn = orderObject.getOrderSn();
		this.userId = orderObject.getUserId();
		this.totalPrice = orderObject.getTotalPrice();
		this.totalSettlementPrice = orderObject.getTotalSettlementPrice();
		this.cashCoin = orderObject.getCashCoin();
		this.promotionId = orderObject.getPromotionId();
		this.promotionDiscount = orderObject.getPromotionDiscount();
		setRedPacketId(orderObject.getRedPacketId());
		setRedPacketFee(orderObject.getRedPacketFee());
		this.totalFee = orderObject.getTotalFee();
		this.commisionFee = orderObject.getCommisionFee();
		this.payTime = orderObject.getPayTime();
		this.payType = orderObject.getPayType();
		this.memberDeliveryAddressId = orderObject.getMemberDeliveryAddressId();
		this.deliveryWay = orderObject.getDeliveryWay();
		this.isBill = orderObject.getIsBill();
		this.billType = orderObject.getBillType();
		this.billHeader = orderObject.getBillHeader();
		this.freight = orderObject.getFreight();
		this.paymentFee = orderObject.getPaymentFee();
		this.linkMan = orderObject.getLinkMan();
		this.mobile = orderObject.getMobile();
		this.province = orderObject.getProvince();
		this.city = orderObject.getCity();
		this.area = orderObject.getArea();
		this.street = orderObject.getStreet();
		this.address = orderObject.getAddress();
		this.lon = orderObject.getLon();
		this.lat = orderObject.getLat();
		this.refundDate = orderObject.getRefundDate();
		this.refundFee = orderObject.getRefundFee();
		this.refundCashCoin = orderObject.getRefundCashCoin();
		this.remark = orderObject.getRemark();
		this.inState = orderObject.getInState();
		this.inDate = orderObject.getInDate();
		this.inVerification = orderObject.getInVerification();
		this.procedureFee = orderObject.getProcedureFee();
		this.bankIn = orderObject.getBankIn();
		this.createTime = orderObject.getCreateTime();
		this.updateTime = orderObject.getUpdateTime();
		this.status = orderObject.getStatus();
		this.refund = orderObject.getRefund();
		this.refundStartTime = orderObject.getRefundStartTime();
		this.commentStatus = orderObject.getCommentStatus();
		this.payId = orderObject.getPayId();
		this.payUrl = orderObject.getPayUrl();
		this.balancePaid = orderObject.getBalancePaid();
		this.taxpayerNo = orderObject.getTaxpayerNo();
		this.remainingTime = getReminningTime(orderObject);
		this.oActivDiscountFee = orderObject.getoActivDiscountFee();
		this.leftTime = getLeftTime(orderObject).toString();
	}

	public void setOrderObjectVo(OrderObject orderObject) {
		this.orderObjectId = orderObject.getId();
		this.orderSn = orderObject.getOrderSn();
		this.userId = orderObject.getUserId();
		this.totalPrice = orderObject.getTotalPrice();
		this.totalSettlementPrice = orderObject.getTotalSettlementPrice();
		this.cashCoin = orderObject.getCashCoin();
		this.promotionId = orderObject.getPromotionId();
		this.promotionDiscount = orderObject.getPromotionDiscount();
		setRedPacketId(orderObject.getRedPacketId());
		setRedPacketFee(orderObject.getRedPacketFee());
		this.totalFee = orderObject.getTotalFee();
		this.commisionFee = orderObject.getCommisionFee();
		//		this.payTime=orderObject.getPayTime();
		this.payTime = orderObject.getPayTime() == null ? "" : orderObject.getPayTime().substring(0, 19);
		this.payType = orderObject.getPayType();
		this.memberDeliveryAddressId = orderObject.getMemberDeliveryAddressId();
		this.deliveryWay = orderObject.getDeliveryWay();
		this.isBill = orderObject.getIsBill();
		this.billType = orderObject.getBillType();
		this.billHeader = orderObject.getBillHeader();
		this.freight = orderObject.getFreight();
		this.paymentFee = orderObject.getPaymentFee();
		this.linkMan = orderObject.getLinkMan();
		this.mobile = orderObject.getMobile();
		this.province = orderObject.getProvince();
		this.city = orderObject.getCity();
		this.area = orderObject.getArea();
		this.street = orderObject.getStreet();
		this.address = orderObject.getAddress();
		this.lon = orderObject.getLon();
		this.lat = orderObject.getLat();
		this.refundDate = orderObject.getRefundDate();
		this.refundFee = orderObject.getRefundFee();
		this.refundCashCoin = orderObject.getRefundCashCoin();
		this.remark = orderObject.getRemark();
		this.inState = orderObject.getInState();
		this.inDate = orderObject.getInDate();
		this.inVerification = orderObject.getInVerification();
		this.procedureFee = orderObject.getProcedureFee();
		this.bankIn = orderObject.getBankIn();
		//		this.createTime=orderObject.getCreateTime();
		this.createTime = orderObject.getCreateTime().substring(0, 19);
		this.updateTime = orderObject.getUpdateTime();
		this.status = orderObject.getStatus();
		this.refund = orderObject.getRefund();
		this.refundStartTime = orderObject.getRefundStartTime();
		this.commentStatus = orderObject.getCommentStatus();
		this.payId = orderObject.getPayId();
		this.payUrl = orderObject.getPayUrl();
		this.balancePaid = orderObject.getBalancePaid();
		this.taxpayerNo = orderObject.getTaxpayerNo();
		this.remainingTime = getReminningTime(orderObject);
		this.oActivDiscountFee = orderObject.getoActivDiscountFee();
		this.leftTime = getLeftTime(orderObject).toString();
	}

	private Long getLeftTime(OrderObject orderObject) {
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		long left = 0L;
		try {
			Date one = df.parse(orderObject.getCreateTime().substring(0, 19));
			left = one.getTime() + 60 * 60 * 1000 - new Date().getTime();//一个小时后再减去当前访问的时间
			if (left < 0) {
				left = 0L;
			} else if (left > 60 * 60 * 1000) {
				left = 60 * 60 * 1000L;
			}
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return left;
	}

	//剩余支付时间（倒计时60分）
	private String getReminningTime(OrderObject orderObject) {
		DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		Date one;
		Date two = new Date();
		long day = 0, hour = 0, min = 0, sec = 0;
		try {
			one = df.parse(orderObject.getCreateTime().substring(0, 19));
			//			System.out.println(two.toLocaleString());
			//			System.out.println("创建时间："+orderObject.getCreateTime().substring(0,19));
			long time1 = one.getTime(), time2 = two.getTime();
			long diff;
			diff = time2 - time1;
			if (diff >= (60 * 60 * 1000)) {
				//				return day + "天" + hour + "小时" + min + "分" + sec + "秒";
				//				System.out.println(sss);
				return min + "分" + sec + "秒";
			} else if (diff < 0) {
				return min + "分" + sec + "秒";
			}
			day = diff / (24 * 60 * 60 * 1000);
			hour = (diff / (60 * 60 * 1000) - day * 24);
			min = 60 - ((diff / (60 * 1000)) - day * 24 * 60 - hour * 60) - 1;
			sec = 60 - (diff / 1000 - day * 24 * 60 * 60 - hour * 60 * 60 - (60 - min - 1) * 60);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		//		System.out.println(day + "天" + hour + "小时" + min + "分" + sec + "秒");
		return min + "分" + sec + "秒";
	}

	public Long getoActivDiscountFee() {
		return oActivDiscountFee;
	}

	public void setoActivDiscountFee(Long oActivDiscountFee) {
		this.oActivDiscountFee = oActivDiscountFee;
	}

	public String getLeftTime() {
		return leftTime;
	}

	public void setLeftTime(String leftTime) {
		this.leftTime = leftTime;
	}

	public String getRemainingTime() {
		return remainingTime;
	}

	public void setRemainingTime(String remainingTime) {
		this.remainingTime = remainingTime;
	}

	public List<OrderInfoVo> getOrderInfoVoList() {
		return orderInfoVoList;
	}

	public void setOrderInfoVoList(List<OrderInfoVo> orderInfoVoList) {
		this.orderInfoVoList = orderInfoVoList;
	}

	public String getTaxpayerNo() {
		return taxpayerNo;
	}

	public void setTaxpayerNo(String taxpayerNo) {
		this.taxpayerNo = taxpayerNo;
	}

	public Long getOrderObjectId() {
		return orderObjectId;
	}

	public void setOrderObjectId(Long orderObjectId) {
		this.orderObjectId = orderObjectId;
	}

	public String getOrderSn() {
		return orderSn;
	}

	public void setOrderSn(String orderSn) {
		this.orderSn = orderSn;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public int getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(int totalPrice) {
		this.totalPrice = totalPrice;
	}

	public int getTotalSettlementPrice() {
		return totalSettlementPrice;
	}

	public void setTotalSettlementPrice(int totalSettlementPrice) {
		this.totalSettlementPrice = totalSettlementPrice;
	}

	public int getCashCoin() {
		return cashCoin;
	}

	public void setCashCoin(int cashCoin) {
		this.cashCoin = cashCoin;
	}

	public int getPromotionId() {
		return promotionId;
	}

	public void setPromotionId(int promotionId) {
		this.promotionId = promotionId;
	}

	public int getPromotionDiscount() {
		return promotionDiscount;
	}

	public void setPromotionDiscount(int promotionDiscount) {
		this.promotionDiscount = promotionDiscount;
	}

	public Integer getRedPacketId() {
		return redPacketId;
	}

	public void setRedPacketId(Integer redPacketId) {
		this.redPacketId = redPacketId;
	}

	public Long getRedPacketFee() {
		return redPacketFee;
	}

	public void setRedPacketFee(Long redPacketFee) {
		this.redPacketFee = redPacketFee;
	}

	public int getTotalFee() {
		return totalFee;
	}

	public void setTotalFee(int totalFee) {
		this.totalFee = totalFee;
	}

	public int getCommisionFee() {
		return commisionFee;
	}

	public void setCommisionFee(int commisionFee) {
		this.commisionFee = commisionFee;
	}

	public String getPayTime() {
		return payTime;
	}

	public void setPayTime(String payTime) {
		this.payTime = payTime;
	}

	public int getMemberDeliveryAddressId() {
		return memberDeliveryAddressId;
	}

	public void setMemberDeliveryAddressId(int memberDeliveryAddressId) {
		this.memberDeliveryAddressId = memberDeliveryAddressId;
	}

	public int getDeliveryWay() {
		return deliveryWay;
	}

	public void setDeliveryWay(int deliveryWay) {
		this.deliveryWay = deliveryWay;
	}

	public int getIsBill() {
		return isBill;
	}

	public void setIsBill(int isBill) {
		this.isBill = isBill;
	}

	public int getBillType() {
		return billType;
	}

	public void setBillType(int billType) {
		this.billType = billType;
	}

	public String getBillHeader() {
		return billHeader;
	}

	public void setBillHeader(String billHeader) {
		this.billHeader = billHeader;
	}

	public int getFreight() {
		return freight;
	}

	public void setFreight(int freight) {
		this.freight = freight;
	}

	public int getPaymentFee() {
		return paymentFee;
	}

	public void setPaymentFee(int paymentFee) {
		this.paymentFee = paymentFee;
	}

	public String getLinkMan() {
		return linkMan;
	}

	public void setLinkMan(String linkMan) {
		this.linkMan = linkMan;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getProvince() {
		return province;
	}

	public void setProvince(String province) {
		this.province = province;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public String getArea() {
		return area;
	}

	public void setArea(String area) {
		this.area = area;
	}

	public String getStreet() {
		return street;
	}

	public void setStreet(String street) {
		this.street = street;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Double getLon() {
		return lon;
	}

	public void setLon(Double lon) {
		this.lon = lon;
	}

	public Double getLat() {
		return lat;
	}

	public void setLat(Double lat) {
		this.lat = lat;
	}

	public String getRefundDate() {
		return refundDate;
	}

	public void setRefundDate(String refundDate) {
		this.refundDate = refundDate;
	}

	public int getRefundFee() {
		return refundFee;
	}

	public void setRefundFee(int refundFee) {
		this.refundFee = refundFee;
	}

	public int getRefundCashCoin() {
		return refundCashCoin;
	}

	public void setRefundCashCoin(int refundCashCoin) {
		this.refundCashCoin = refundCashCoin;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public int getInState() {
		return inState;
	}

	public void setInState(int inState) {
		this.inState = inState;
	}

	public String getInDate() {
		return inDate;
	}

	public void setInDate(String inDate) {
		this.inDate = inDate;
	}

	public String getInVerification() {
		return inVerification;
	}

	public void setInVerification(String inVerification) {
		this.inVerification = inVerification;
	}

	public int getProcedureFee() {
		return procedureFee;
	}

	public void setProcedureFee(int procedureFee) {
		this.procedureFee = procedureFee;
	}

	public int getBankIn() {
		return bankIn;
	}

	public void setBankIn(int bankIn) {
		this.bankIn = bankIn;
	}

	public String getCreateTime() {
		return createTime;
	}

	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}

	public String getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(String updateTime) {
		this.updateTime = updateTime;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public int getRefund() {
		return refund;
	}

	public void setRefund(int refund) {
		this.refund = refund;
	}

	public int getRefundStartTime() {
		return refundStartTime;
	}

	public void setRefundStartTime(int refundStartTime) {
		this.refundStartTime = refundStartTime;
	}

	public int getCommentStatus() {
		return commentStatus;
	}

	public void setCommentStatus(int commentStatus) {
		this.commentStatus = commentStatus;
	}

	public List<PayTypeConfig> getPayTypeConfigList() {
		return payTypeConfigList;
	}

	public void setPayTypeConfigList(List<PayTypeConfig> payTypeConfigList) {
		this.payTypeConfigList = payTypeConfigList;
	}

	public String getPayId() {
		return payId;
	}

	public void setPayId(String payId) {
		this.payId = payId;
	}

	public String getPayUrl() {
		return payUrl;
	}

	public void setPayUrl(String payUrl) {
		this.payUrl = payUrl;
	}

	public Integer getPayType() {
		return payType;
	}

	public void setPayType(Integer payType) {
		this.payType = payType;
	}

	public int getBalancePaid() {
		return balancePaid;
	}

	public void setBalancePaid(int balancePaid) {
		this.balancePaid = balancePaid;
	}

	public int getIsOverseasOrder() {
		return isOverseasOrder;
	}

	public void setIsOverseasOrder(int isOverseasOrder) {
		this.isOverseasOrder = isOverseasOrder;
	}
}
